能把我急死。为什么qt里面用起来那么方便的东西回到C++感觉好复杂的样子
const std:: regex hexPattern("^[0-9a-fA-F]{6}$");//定义六进制颜色的正则表达式
std::smatch hexMatch;
std::string hex_color = strings[code.StrTranslate(code.SplitCode(code_line,1))];
if(! std::regex_match (hex_color, hexPattern ))
{
cout<<"16进制颜色格式错误,请输入形如FF8000的六位16进制数(不区分大小写)!"<<endl;
error_message.push_back("16进制颜色格式错误,请输入形如FF8000的六位16进制数(不区分大小写)!");
hex_color = "FF8000";
}
//cout<<hex_color;
int color[3];
char * str;
//cout<<hex_color[0];
for(int i=0; i<5; i+=2)
{
std::string temp ="0x"+hex_color.substr(i,2);
//cout<<temp<<endl;
color[i/2] = (int)strtol(temp.c_str(), &str, 16);
}
//cout<<color[0]<<endl<<color[1]<<endl<<color[2]<<endl;